package com.example.myandroidapp1;


import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.example.myandroidapp1.activity.AbstractBaseActivity;

public class StatusBarActivity extends AbstractBaseActivity implements
		OnClickListener {

	NotificationManager nm;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.statusbar);
		Button stat = (Button) findViewById(R.id.btStatusBar);
		stat.setOnClickListener(this);
		nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
	}

	@Override
	public void onClick(View v) {
		Intent intent = new Intent(this, StatusBarActivity.class);
		PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
		String body = "This is a message from Nikunj. Thanks for your support.";
		String title = "MyAndroid APP";
		Notification noti = new Notification.Builder(this)
				.setContentTitle(title)
				.setTicker(title)
				.setDefaults(Notification.DEFAULT_ALL)
				.setContentText(body).setSmallIcon(R.drawable.ic_launcher)
				.setContentIntent(pi).build();

		noti.flags |= Notification.FLAG_AUTO_CANCEL;
		nm.notify(0, noti);
		
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		finish();
	}

}
